package edu.uta.cfl.engine;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.regex.Pattern;

import edu.uta.cfl.GUI.LoadRecommendedTestSet;
import edu.uta.cfl.data.IterationResult;
import edu.uta.cfl.data.SUT;
import edu.uta.cfl.data.SUT.SUTState;
import edu.uta.cfl.util.Util;
import edu.uta.cfl.util.Util.MSGType;


/**
 * This class will update the test set and result in the SUT
 * based on the inputs provided for every iteration
 * starting from iteration 2 to iteration 6.
 */

public class UpdateTestSet {
	private SUT sut;
	private IterationResult iteration;
	private ArrayList<Integer> resultsFromUser;
	public final int ADD = 1;

	public UpdateTestSet(SUT sut,IterationResult itr,ArrayList<Integer> results) {
		super();
		this.iteration =itr;
		this.sut = sut;
		this.resultsFromUser = results;
	}

	public void addTestSet()
	{
		int level = findNextLevel();
		ArrayList<int[]> testSet = iteration.getTestSet(); // RTS from previous iteration
		//ArrayList<Integer> testSetResult = resultsFromUser;
		for(int count =0; count<testSet.size();count++)
		{
			sut.getTs().getMatrix().add(count, testSet.get(count));
			sut.getTs().getResult().add(count, resultsFromUser.get(count));
			sut.getTs().getLevelAdded().add(level);
		}

	}

	private int findNextLevel(){
			return Collections.max(sut.getTs().getLevelAdded()) + 1;
		}

}
